**# get data using your directory information
	cd "" 
	use "CFDIAS_data.dta", clear

**# Create Figure 1
	twoway (line avg_SOEsSan year,lpattern(dash) lcolor("red")) ///
	(line avg_SOEsNoSan year,lpattern(dash) lcolor("green")) ///
	(line avg_privateSan year,lpattern(dash) lcolor("blue")) ///
	(line avg_privateNoSan year,lpattern(dash) lcolor("orange")) ///
	if year>2004 & year<2016, ///
	title("Chinese Overseas FDI", size(vlarge)) ///
	subtitle("Average Annual Investment in Millions of USD") xtitle("") xlabel(2005(1)2015, labsize(small)) ///
	legend(row(2) position(7))

**# Create Table 1
	* Define Covariates
	global cov llnfdinetinflows2 lWDIGDPGrPer2 lBITChinForce2 lWDITradePerGDP2 ///
	lexecrlc2 lTotNatResRentPerGDP2 lMarshactotalD2 llnVDemv2x_rule2 ///
	llnVDemv2x_libdem2 llnWDIGDP2 lka_open2 llndurable2 lUSFDIBEAPGDP2 ///
	asia eeurop lamerica nafrme
	
	* generate weights with ebalance
	ebalance SanBal $cov, gen(weight)
	drop if weight==.
		
	* Make Balanced Vs. Unbalanced Comparison of Covariate Means Before and After Treatement 
	eststo clear
	eststo: quietly regress llnfdinetinflows2 SanBal 	
	eststo: quietly regress llnfdinetinflows2 0.SanBal   	
	eststo: quietly regress llnfdinetinflows2 SanBal   [aweight=weight]
	eststo: quietly regress llnfdinetinflows2 0.SanBal [aweight=weight]
	esttab, label b(2) nose not star(* 0.1 ** 0.05 *** 0.01) varwidth(12) modelwidth(24) nonumbers 

	eststo clear
	eststo: quietly regress lWDIGDPGrPer2 SanBal 	
	eststo: quietly regress lWDIGDPGrPer2 0.SanBal   	
	eststo: quietly regress lWDIGDPGrPer2 SanBal   [aweight=weight]
	eststo: quietly regress lWDIGDPGrPer2 0.SanBal [aweight=weight]
	esttab, label b(2) nose not star(* 0.1 ** 0.05 *** 0.01) varwidth(12) modelwidth(24) nonumbers 

	eststo clear
	eststo: quietly regress lBITChinForce2 SanBal 	
	eststo: quietly regress lBITChinForce2 0.SanBal   	
	eststo: quietly regress lBITChinForce2 SanBal   [aweight=weight]
	eststo: quietly regress lBITChinForce2 0.SanBal [aweight=weight]
	esttab, label b(2) nose not star(* 0.1 ** 0.05 *** 0.01) varwidth(12) modelwidth(24) nonumbers 

	eststo clear
	eststo: quietly regress lWDITradePerGDP2 SanBal 	
	eststo: quietly regress lWDITradePerGDP2 0.SanBal   	
	eststo: quietly regress lWDITradePerGDP2 SanBal   [aweight=weight]
	eststo: quietly regress lWDITradePerGDP2 0.SanBal [aweight=weight]
	esttab, label b(2) nose not star(* 0.1 ** 0.05 *** 0.01) varwidth(12) modelwidth(24) nonumbers 

	eststo clear
	eststo: quietly regress lexecrlc2 SanBal 	
	eststo: quietly regress lexecrlc2 0.SanBal   	
	eststo: quietly regress lexecrlc2 SanBal   [aweight=weight]
	eststo: quietly regress lexecrlc2 0.SanBal [aweight=weight]
	esttab, label b(2) nose not star(* 0.1 ** 0.05 *** 0.01) varwidth(12) modelwidth(24) nonumbers 

	eststo clear
	eststo: quietly regress lTotNatResRentPerGDP2 SanBal 	
	eststo: quietly regress lTotNatResRentPerGDP2 0.SanBal   	
	eststo: quietly regress lTotNatResRentPerGDP2 SanBal   [aweight=weight]
	eststo: quietly regress lTotNatResRentPerGDP2 0.SanBal [aweight=weight]
	esttab, label b(2) nose not star(* 0.1 ** 0.05 *** 0.01) varwidth(12) modelwidth(24) nonumbers 

	eststo clear
	eststo: quietly regress lMarshactotalD2 SanBal 	
	eststo: quietly regress lMarshactotalD2 0.SanBal   	
	eststo: quietly regress lMarshactotalD2 SanBal   [aweight=weight]
	eststo: quietly regress lMarshactotalD2 0.SanBal [aweight=weight]
	esttab, label b(2) nose not star(* 0.1 ** 0.05 *** 0.01) varwidth(12) modelwidth(24) nonumbers 

	eststo clear
	eststo: quietly regress llnVDemv2x_rule2 SanBal 	
	eststo: quietly regress llnVDemv2x_rule2 0.SanBal   	
	eststo: quietly regress llnVDemv2x_rule2 SanBal   [aweight=weight]
	eststo: quietly regress llnVDemv2x_rule2 0.SanBal [aweight=weight]
	esttab, label b(2) nose not star(* 0.1 ** 0.05 *** 0.01) varwidth(12) modelwidth(24) nonumbers 

	eststo clear
	eststo: quietly regress llnVDemv2x_libdem2 SanBal 	
	eststo: quietly regress llnVDemv2x_libdem2 0.SanBal   	
	eststo: quietly regress llnVDemv2x_libdem2 SanBal   [aweight=weight]
	eststo: quietly regress llnVDemv2x_libdem2 0.SanBal [aweight=weight]
	esttab, label b(2) nose not star(* 0.1 ** 0.05 *** 0.01) varwidth(12) modelwidth(24) nonumbers 

	eststo clear
	eststo: quietly regress llnWDIGDP2 SanBal 	
	eststo: quietly regress llnWDIGDP2 0.SanBal   	
	eststo: quietly regress llnWDIGDP2 SanBal   [aweight=weight]
	eststo: quietly regress llnWDIGDP2 0.SanBal [aweight=weight]
	esttab, label b(2) nose not star(* 0.1 ** 0.05 *** 0.01) varwidth(12) modelwidth(24) nonumbers 
 
	eststo clear
	eststo: quietly regress lka_open2 SanBal 	
	eststo: quietly regress lka_open2 0.SanBal   	
	eststo: quietly regress lka_open2 SanBal   [aweight=weight]
	eststo: quietly regress lka_open2 0.SanBal [aweight=weight]
	esttab, label b(2) nose not star(* 0.1 ** 0.05 *** 0.01) varwidth(12) modelwidth(24) nonumbers 

	eststo clear
	eststo: quietly regress llndurable2 SanBal 	
	eststo: quietly regress llndurable2 0.SanBal   	
	eststo: quietly regress llndurable2 SanBal   [aweight=weight]
	eststo: quietly regress llndurable2 0.SanBal [aweight=weight]
	esttab, label b(2) nose not star(* 0.1 ** 0.05 *** 0.01) varwidth(12) modelwidth(24) nonumbers 

	eststo clear
	eststo: quietly regress lUSFDIBEAPGDP2 SanBal 	
	eststo: quietly regress lUSFDIBEAPGDP2 0.SanBal   	
	eststo: quietly regress lUSFDIBEAPGDP2 SanBal   [aweight=weight]
	eststo: quietly regress lUSFDIBEAPGDP2 0.SanBal [aweight=weight]
	esttab, label b(2) nose not star(* 0.1 ** 0.05 *** 0.01) varwidth(12) modelwidth(24) nonumbers 

	eststo clear
	eststo: quietly regress asia SanBal 	
	eststo: quietly regress asia 0.SanBal   	
	eststo: quietly regress asia SanBal   [aweight=weight]
	eststo: quietly regress asia 0.SanBal [aweight=weight]
	esttab, label b(2) nose not star(* 0.1 ** 0.05 *** 0.01) varwidth(12) modelwidth(24) nonumbers 

	eststo clear
	eststo: quietly regress eeurop SanBal 	
	eststo: quietly regress eeurop 0.SanBal   	
	eststo: quietly regress eeurop SanBal   [aweight=weight]
	eststo: quietly regress eeurop 0.SanBal [aweight=weight]
	esttab, label b(2) nose not star(* 0.1 ** 0.05 *** 0.01) varwidth(12) modelwidth(24) nonumbers 

	eststo clear
	eststo: quietly regress lamerica SanBal 	
	eststo: quietly regress lamerica 0.SanBal   	
	eststo: quietly regress lamerica SanBal   [aweight=weight]
	eststo: quietly regress lamerica 0.SanBal [aweight=weight]
	esttab, label b(2) nose not star(* 0.1 ** 0.05 *** 0.01) varwidth(12) modelwidth(24) nonumbers 

	eststo clear
	eststo: quietly regress nafrme SanBal 	
	eststo: quietly regress nafrme 0.SanBal   	
	eststo: quietly regress nafrme SanBal   [aweight=weight]
	eststo: quietly regress nafrme 0.SanBal [aweight=weight]
	esttab, label b(2) nose not star(* 0.1 ** 0.05 *** 0.01) varwidth(12) modelwidth(24) nonumbers 

**# Create Table 2 using covariate list and weights from previous section 
	est clear
	reg lnSOE SanUS ThUS $cov i.year [aweight=weight], cluster(ccode) 
	eststo m1
	vif
		
	reg lnPOE SanUS ThUS $cov i.year [aweight=weight], cluster(ccode)
	eststo m2
	vif

	reg  lnSOE_E SanUS ThUS $cov i.year [aweight=weight], cluster(ccode)
	eststo m3
	vif
	
	reg lnPOE_E SanUS ThUS $cov i.year [aweight=weight], cluster(ccode)
	eststo m4
	vif
 
	reg lnSOE_NE SanUS ThUS $cov i.year [aweight=weight], cluster(ccode)
	eststo m5
	vif

	reg lnPOE_NE SanUS ThUS $cov i.year [aweight=weight], cluster(ccode)
	eststo m6
	vif
	
	esttab, bic replace onecell nogap obslast star(* .1 ** .05 *** .01) label  b(2) t(2) 
	